package com.gdth.widget.viewpager.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class BasePagerAdapter extends PagerAdapter{
	/**
	 * 把需要滑动的页卡添加到这个list中   
	 */
	private List<View> viewList;					
	
	/**
	 * 构造函数
	 * @param viewList
	 */
	public BasePagerAdapter(List<View> viewList)
	{
		this.viewList = viewList;
	}
	
	@Override  
    public boolean isViewFromObject(View arg0, Object arg1) {  
        return arg0 == arg1;  
    }  

    @Override  
    public int getCount() {  
        return viewList.size();  
    }  
   
    @Override  
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);  
    }  
    
    @Override  
    public void destroyItem(ViewGroup container, int position, Object object) {  
        container.removeView(viewList.get(position));  
    }

    @Override  
    public Object instantiateItem(ViewGroup container, int position) {  
        container.addView(viewList.get(position));  
        return viewList.get(position);  
    } 
}
